﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<IEnumerable<TheWorldsWorst.ApiWrapper.Model.User>>" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Users -  TWWSOC</title>
    <link rel="Stylesheet" href="../../Content/all.css" />
</head>
<body>
<style type="text/css">
    .user-info { clear:both; height:45px; }
</style>
<div class="container">
    <div id="header">
        <div id="topbar">
        </div>
        <br class="cbt"/>
        <div id="hlogo">
            <a href="/"><img src="../../Content/img/logo.png" alt="The World's Worst StackOverflow Clone"/></a>
        </div>
        <%= StackOverflow.Api.ExampleApp.Views.Shared.Format.Header("users") %>
    </div>
    <div id="content">
        <div id="mainbar-full">    
            <div id="subheader">
                <h2>Users</h2>
                <div id="tabs">
				    <a <% if("reputation".Equals(ViewData["Tab"])){ %>class="youarehere"<% } %> href="/users" title="Users with the highest reputation scores">reputation</a>
				    <a <% if("newest".Equals(ViewData["Tab"])){ %>class="youarehere"<% } %> href="/users?tab=newest" title="Users who joined recently">newest</a>
				    <a <% if("oldest".Equals(ViewData["Tab"])){ %>class="youarehere"<% } %> href="/users?tab=oldest" title="Users who have been members the longest">oldest</a>
				    <a <% if("name".Equals(ViewData["Tab"])){ %>class="youarehere"<% } %> href="/users?tab=name" title="Users in alphabetical order by display name">name</a>
                </div>          
            </div>
        </div>
        <div class="page-description"> 
            <table> 
                <tr> 
                    <td style="vertical-align:middle">Type to find users:</td> 
                    <td style="vertical-align:middle; padding-left:5px"><input id="userfilter" name="userfilter" class="userfilter" type="text"></td> 
                </tr> 
            </table>    
        </div>
        <div id="user-browser">
            <table style="width:940px; margin-left:20px; margin-top:-10px"> 
                <tr>
                    <%  var users = Model.ToList();
                        for (int i = 0; i < 5; i++) { %>
                    <td>
                        <% 
                            for (int j = 0; j < 7; j++) {
                                if (users.Count > (i * 7) + j)
                                    Response.Write(StackOverflow.Api.ExampleApp.Views.Shared.Format.UserListing(users[(i * 7) + j]));
                                else
                                    break;
                            } 
                        %>
                    </td>
                    <% } %>
                </tr>
            </table>        
        </div>
        
        <div id="paging-controls" style="float:right; margin-bottom:20px"> 
            <div class="pager">
                <%-- TODO: Refactor this to something reusable (and pretty)--%>
                <% int page = (int)ViewData["Page"]; %>
                <% if (page < 5) { 
                       for (int i = 1; i < page; i++) {%>
                <a href="/users?page=<%=i%>&amp;tab=<%=ViewData["Tab"]%>" title="go to page <%=i%>"><span class="page-numbers"><%=i%></span></a> 
                       <% } %>
                <% } else { %>
                <a href="/users?page=<%=page-1%>&amp;tab=<%=ViewData["Tab"]%>" title="go to page <%=page-1%>" rel="prev"><span class="page-numbers prev"> prev</span></a> 
                <a href="/users?page=1&amp;tab=<%=ViewData["Tab"]%>" title="go to page 1"><span class="page-numbers">1</span></a> 
                <span class="page-numbers dots">&hellip;</span> 
                    <% for (int i = page - 2; i < page; i++) { %>
                <a href="/users?page=<%=i%>&amp;tab=<%=ViewData["Tab"]%>" title="go to page <%=i%>"><span class="page-numbers"><%=i%></span></a>     
                    <% } %>
                <% } %>
                <span class="page-numbers current"><%=page%></span> 
                <% if (page < 5) { 
                       for (int i = page + 1; i < 6; i++) { %>
                <a href="/users?page=<%=i%>&amp;tab=<%=ViewData["Tab"]%>" title="go to page <%=i%>"><span class="page-numbers"><%=i%></span></a> 
                    <% } %>
                <span class="page-numbers dots">&hellip;</span> 
                <% } else { %>
                    <% for (int i = page +1; i < page + 3; i++) { %>
                <a href="/users?page=<%=i%>&amp;tab=<%=ViewData["Tab"]%>" title="go to page <%=i%>"><span class="page-numbers"><%=i%></span></a> 
                    <% } %>
                <span class="page-numbers dots">&hellip;</span> 
                <% } %>
                <a href="/users?page=<%=ViewData["PageMax"]%>&amp;tab=<%=ViewData["Tab"]%>" title="go to page <%=ViewData["PageMax"]%>"><span class="page-numbers"><%=ViewData["PageMax"]%></span></a> 
                <a href="/users?page=<%=page+1%>&amp;tab=<%=ViewData["Tab"]%>" title="go to page <%=page+1%>" rel="next"><span class="page-numbers next"> next</span></a> 
            </div>  
        </div>
    </div>
</div>

</body>
</html>
